package GormSrv

import (
	"fmt"
	"github.com/jinzhu/gorm"
)

func ThrowDBError(db *gorm.DB) interface{} {
	errors := db.GetErrors()

	if len(errors) > 0 {
		var errorMessage = ""
		for _, err := range errors {
			fmt.Println("[error]:", err.Error())
			errorMessage += err.Error() + ";"
		}
		panic(errorMessage)
	}

	return db
}
